<!--Copyright (C) Kherty.  All rights reserved.-->
<ResourceDictionary
    x:Class="OpenLS.Chart.UI.ChartAreaResources"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:chart="http://schemas.Kherty.com/office/2007/chart"
    xmlns:chartui="clr-namespace:OpenLS.Chart.UI"
        xmlns:drawing="http://schemas.Kherty.com/office/2007/drawing"
    xmlns:drawing2="clr-namespace:OpenLS.Drawing.UI;assembly=OpenLS.Drawing.UI"
    xmlns:Internals="clr-namespace:OpenLS.Chart.UI.Internals" 
    xmlns:Internals1="clr-namespace:OpenLS.Drawing.UI.Internals;assembly=OpenLS.Drawing.UI">
    <DataTemplate DataType="{x:Type chart:ChartArea}" >
        <Grid SnapsToDevicePixels="False" Name="chartAreaGrid"
            chartui:ChartElement.ChartArea="{Binding}" Loaded="OnChartAreaLoaded"
                        chartui:ChartElement.Style="{Binding Style}" 
          chartui:ChartElement.InheritedTheme="{Binding RelativeSource={RelativeSource Self}, Path=(drawing2:DrawingElement.Theme)}"
        
              
> 
              
            <Grid.CommandBindings>
                <CommandBinding Command="{x:Static chartui:ChartCommands.SetChartStyle}" Executed ="OnSetStyle"></CommandBinding>
                <CommandBinding Command="{x:Static chartui:ChartCommands.FormatChartArea}" Executed="OnFormatChartArea"/>
                <CommandBinding Command="{x:Static chartui:ChartCommands.Format3DRotation}" Executed="OnFormat3DRotation"/>
            </Grid.CommandBindings
                >
           <!-- <drawing:DrawingElement.Theme>
                <MultiBinding Converter="{x:Static Internals:ChartConverters.ThemeConverter}">
                    <Binding Path="Theme"/>
                    <Binding
            RelativeSource="{RelativeSource Mode=FindAncestor, AncestorType={x:Type FrameworkElement}, AncestorLevel=1}"
            Path="(drawing2:DrawingElement.Theme)"/>
                </MultiBinding>
            </drawing:DrawingElement.Theme> -->
            <Grid.ContextMenu>
                <ContextMenu>
                    <MenuItem Command="{x:Static chartui:ChartCommands.FormatChartArea}"/>
                </ContextMenu>
            </Grid.ContextMenu>
            <Rectangle Style="{x:Static chartui:ShapedObjectResources.ShapedObjectStyle}" Name="chartAreaRect"
                       StrokeDashArray="{Binding RelativeSource={RelativeSource Self}, Path=(drawing2:DrawingElement.ShapeProperties).LineProperties.LineDashProperties, Converter={x:Static Internals:ChartConverters.LineDashPropertiesToStrokeDashArrayConverter}}"
            StrokeEndLineCap="{Binding RelativeSource={RelativeSource Self} , Path=(drawing2:DrawingElement.ShapeProperties).LineProperties.LineCap, Converter={x:Static Internals1:DrawingConverters.LineCapConverter}}"
            StrokeStartLineCap="{Binding RelativeSource={RelativeSource Self} ,Path=(drawing2:DrawingElement.ShapeProperties).LineProperties.LineCap, Converter={x:Static Internals1:DrawingConverters.LineCapConverter}}"
            StrokeThickness="{Binding RelativeSource={RelativeSource Self} ,Path=(drawing2:DrawingElement.ShapeProperties).LineProperties.Width, FallbackValue=1}"
            >
                <Rectangle.Fill>
                    <MultiBinding Converter="{x:Static Internals:ChartConverters.ChartAreaFillToBackgroundConverter}">
                        <Binding Path="ShapeProperties.FillProperties"/>
                        <Binding RelativeSource ="{RelativeSource Self}" Path="(drawing2:DrawingElement.ColorScheme)"/>
                        <Binding RelativeSource ="{RelativeSource Self}" Path="(chartui:ChartElement.Style)"/>
                        <Binding RelativeSource="{RelativeSource Self}"></Binding>
                    </MultiBinding>
                </Rectangle.Fill>
                <Rectangle.Stroke>
                    <MultiBinding Converter="{x:Static  Internals:ChartConverters.LineFillPropertiesSchemeIndexToBrushConverter}">
                        <Binding RelativeSource="{RelativeSource Self}" Path="(drawing2:DrawingElement.ShapeProperties).LineProperties.LineFillProperties"/>
                        <Binding RelativeSource="{RelativeSource Self}" Path="(drawing2:DrawingElement.ColorScheme)"/>
                    </MultiBinding>
                </Rectangle.Stroke>

            </Rectangle>
            <chartui:ChartPanel
                Focusable ="True"
                
      Style="{x:Static chartui:ChartHelperResources.FocusableByClickStyle}" 
                chartui:ChartElement.View3D="{Binding View3D}">

                <TextElement.Foreground>
                    <MultiBinding Converter="{x:Static Internals:ChartConverters.ColorBaseToBrushConverter}">
                        <Binding RelativeSource ="{RelativeSource Self}" Path="(chartui:ChartElement.Style).AxisColor"/>
                        <Binding RelativeSource ="{RelativeSource Self}" Path="(drawing2:DrawingElement.ColorScheme)"/>
                    </MultiBinding>
                </TextElement.Foreground>

                <ContentPresenter Content="{Binding Path=Title}" chartui:ChartPanel.Position="Top" TextElement.FontSize="24" 
                          chartui:ChartPanel.Overlay="{Binding Path=Overlay}" Panel.ZIndex="2"/>
                <ContentPresenter Content="{Binding Path=Legend}"
                          chartui:ChartPanel.Position="{Binding Path=Position}"
                          chartui:ChartPanel.Overlay="{Binding Path=Overlay}"
                          VerticalAlignment="Center"
                          HorizontalAlignment="Center" Panel.ZIndex="3"
                          />
                <ContentControl Content="{Binding Path=PlotArea}" Margin ="3"/>
            </chartui:ChartPanel>
        </Grid>
        <DataTemplate.Triggers>
            <DataTrigger Binding="{Binding RoundedCorners}" Value="True">
                <Setter TargetName="chartAreaRect" Property="RadiusX" Value="15"/>
                <Setter TargetName="chartAreaRect" Property="RadiusY" Value="15"/>
            </DataTrigger>
            
            <DataTrigger Binding="{Binding Theme}" Value="{x:Null}">
                <Setter TargetName="chartAreaGrid" Property="drawing2:DrawingElement.Theme">
                    <Setter.Value>
                        <Binding
            RelativeSource="{RelativeSource Mode=FindAncestor, AncestorType={x:Type FrameworkElement}, AncestorLevel=1}"
            Path="(drawing2:DrawingElement.Theme)"/>

                    </Setter.Value>
                </Setter>
            </DataTrigger>
           <MultiDataTrigger >
                <MultiDataTrigger.Conditions>
                    <Condition Binding="{Binding Theme}" Value="{x:Null}">
                    </Condition>
                    <Condition Value="{x:Null}">
                        <Condition.Binding>
                            <Binding RelativeSource="{RelativeSource Mode=FindAncestor, AncestorType={x:Type FrameworkElement}, AncestorLevel=1}" Path="(drawing2:DrawingElement.Theme)"/>
                        </Condition.Binding>
                    </Condition>
                </MultiDataTrigger.Conditions>
                <Setter TargetName="chartAreaGrid" Property="drawing:DrawingElement.Theme" Value="{x:Static drawing:BuiltInThemes.DefaultTheme }" />
            </MultiDataTrigger>
        </DataTemplate.Triggers>
    </DataTemplate>
    
</ResourceDictionary>